// struct2.c
// gcc struct2.c

#include <stdio.h>
#include <stdlib.h>

typedef struct Student
{
    char name[10];
    int  eng;
    int  math;
}STUDENT;

void inputStudent(STUDENT *);
void printStudent(STUDENT *);

int main()
{
    STUDENT stu;
    
    inputStudent(&stu);
    printStudent(&stu);
    
    printf("\n");
    system("pause");
    return 0;
}

void inputStudent(STUDENT *pst)
{
    printf("sizeof(STUDENT) = %d byte(s)\n",sizeof(STUDENT));
    printf("sizeof(pst)     = %d byte(s)\n",sizeof(pst));
    printf("\n");
    printf("name : ");  gets(pst->name);
    printf("eng  : ");  scanf("%d",&pst->eng);
    printf("math : ");  scanf("%d",&pst->math);
    printf("\n");
}

void printStudent(STUDENT *pst)
{
    printf("Name\tEng\tMath\tSum\tAvg\n");
    printf("---------------------------------------\n");
    printf("%s\t%d\t%d\t%d\t%.2f\n", 
           pst->name, 
           pst->eng, 
           pst->math,
           pst->eng + pst->math,
           (pst->eng + pst->math)/2.0);
}